package cn.iocoder.yudao.module.trade.aftersale.vo;

import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.api.trade.aftersale.enums.AfterSaleWayEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.util.List;

@Schema(description = "用户 App - 售后订单创建 Request VO")
@Data
public class AppAfterSaleCreateReqVO {

    @Schema(description = "订单编号，【整单退款】时使用", example = "1024")
    private Long orderId;

    @Schema(description = "订单项编号，【单个产品退款】时使用", example = "1024")
    private Long orderItemId;

    @SuppressWarnings("unused")
    @AssertTrue(message = "订单编号和订单项编号不能同时为空")
    public boolean validateOrderIdAndOrderItemId() {
        return (orderId != null && orderId > 0) || (orderItemId != null && orderItemId > 0);
    }

    @Schema(description = "售后方式：0-无退款、10-仅退款、20-退货退款", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @NotNull(message = "售后方式不能为空")
    @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}")
    private Integer way;

    @Schema(description = "退款金额，默认为订单实付款，不能超过订单实付款", example = "100")
    private Integer refundPrice;

    @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不想要了")
    @NotNull(message = "申请原因不能为空")
    @Length(max = 100, message = "申请原因长度不能超过 100")
    private String applyReason;

    @Schema(description = "补充描述", example = "产品质量不好")
    @Length(max = 255, message = "补充描述长度不能超过 255")
    private String applyDescription;

    @Schema(description = "补充凭证图片")
    @Size(max = 9, message = "图片不能超过 9 张")
    private List<String> applyPicUrls;

}
